package com.aynu.admin.service.base.impl;

import cn.hutool.system.SystemUtil;
import com.aynu.admin.domain.CommonResponse;
import com.aynu.admin.domain.vo.DynamicSystemInfo;
import com.aynu.admin.domain.vo.StaticSystemInfo;
import com.aynu.admin.service.base.ISystemService;
import org.springframework.stereotype.Service;

@Service
public class SystemService implements ISystemService {
    @Override
    public CommonResponse<StaticSystemInfo> staticSystemInfo() {
        StaticSystemInfo staticSystemInfo=new StaticSystemInfo(
                SystemUtil.getJvmInfo(),
                SystemUtil.getOsInfo(),
                SystemUtil.getJavaRuntimeInfo(),
                SystemUtil.getUserInfo()
        );
        return CommonResponse.success(staticSystemInfo);
    }

    @Override
    public CommonResponse<DynamicSystemInfo> dynamicSystemInfoList() {
        DynamicSystemInfo dynamicSystemInfo=new DynamicSystemInfo(
                SystemUtil.getMaxMemory(),//4046
                SystemUtil.getFreeMemory(),//31
                SystemUtil.getMemoryMXBean().getHeapMemoryUsage().getMax(),//4046
                SystemUtil.getMemoryMXBean().getHeapMemoryUsage().getUsed()//76
        );

        return CommonResponse.success(dynamicSystemInfo);
    }
}
